import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);

import Mobile from '@/view/Mobile.vue'
import MobileHome from '@/view/mobile/MobileHome.vue';
import MobileHeader from '@/components/mobile/default/MobileHeader.vue';
import MobileFooter from '@/components/mobile/default/MobileFooter.vue';
import MobileBooksList from '@/view/mobile/MobileBooksList.vue';
import MobileMeList from '@/view/mobile/MobileMeList.vue';
import MobileHomeList from '@/components/mobile/home/MobileHomeList.vue';
import MobileHomeMe from '@/components/mobile/home/MobileHomeMe.vue';
import Home from '@/view/pc/Home.vue';
import AdminLogin from '@/components/admin/AdminLogin.vue';
import MobileSearch from '@/view/mobile/MobileSearch.vue'

//详情页
import MobileDetail from '@/view/mobile/MobileDetail.vue'

// 购物车
import MobileCar from '@/view/mobile/MobileCar.vue'


// 后台管理 管理员主页
import AdmMain from '@/components/admin/adm/AdmMain.vue'
import Backstage from '@/components/admin/adm/backstage/Backstage'

// 热度图片
import HotPic from '@/components/admin/adm/hotpic/HotPic.vue'
// 热度图片添加
import HotPicAdd from '@/components/admin/adm/hotpic/HotPicAdd.vue'

// 一级类型
import FirstType from '@/components/admin/adm/typemanage/FirstType.vue'
// 二级类型
import SecondType from '@/components/admin/adm/typemanage/SecondType.vue'

// 商品列表
import BookList from '@/components/admin/adm/bookmange/BookList.vue'
// 添加商品列表 
import AddBookList from '@/components/admin/adm/bookmange/AddBookList'

// 冻结密码重置
import UpdataPwd from '@/components/admin/adm/usermanage/UpdataPwd.vue'
// 管理员添加
import AdmAdd from '@/components/admin/adm/usermanage/AdmAdd.vue'
// 订单详情
import OrderDetail from '@/components/admin/adm/ordermanage/OrderDetail.vue'
// 移动端登录页
import MobileLogin from '@/components/mobile/home/MobileLogin.vue'
const routes = [{
		path: '/',
		// component : Home
		// redirect : {
		// 	name : Home
		// }
		// redirect: '/mobile/home', //移动端
		redirect: '/adminlogin', //默认显示后台管理登录页
		// redirect: '/mobileLogin', //移动端登录页面
	},
	{
		path: '/mobileLogin',
		name: 'MobileLogin',
		component: MobileLogin
	},
	{
		path: '/home',
		name: 'Home',
		component: Home
	},
	{
		path: '/mobile',
		name: 'Mobile',
		component: Mobile,
		children: [{
				path: 'home',
				name: 'MobileHome',
				//下面所使用的是：命名视图的方式，为router-view的 name 属性匹配组件
				components: {
					default: MobileHome, //渲染到没有name 属性的router-view上
					header: MobileHeader,
					footer: MobileFooter
				}
			},
			{
				path: 'bookslist',
				name: 'MobileBooksList',
				components: {
					default: MobileBooksList,
					header: MobileHeader,
					footer: MobileFooter
				}
			},
			{
				path: 'search',
				name: 'MobileSearch',
				component: MobileSearch
			},
			// 我的主页
			{
				path: 'melist',
				name: 'MobileMeList',
				components: {
					default: MobileMeList,
					header: MobileHeader,
					footer: MobileFooter
				}
			},
			{
				path: 'bookdetail/:bookid',
				name: 'MobileDetail',
				component: MobileDetail
			},
			{
				path: 'mobileCar',
				name: 'MobileCar',
				component: MobileCar
			}
		]
	},
	{
		path: '/adminlogin',
		name: 'AdminLogin',
		component: AdminLogin
	},
	{
		path: '/adm',
		name: 'AdmMain',
		component: AdmMain,

		children: [
			{
				path: 'backstage',
				name: 'Backstage',
				component: Backstage
			},
			
			// 热度图片
			{
				path: 'hotPic',
				name: 'HotPic',
				component: HotPic
			},
			// 添加热度图片
			{
				path: 'hotPicAdd',
				name: 'HotPicAdd',
				component: HotPicAdd
			},

			// 一级类型
			{
				path: 'firstType',
				name: 'FirstType',
				component: FirstType
			},
			// 二级类型
			{
				path: 'secondType',
				name: 'SecondType',
				component: SecondType
			},
			// 商品列表
			{
				path: 'bookList',
				name: 'BookList',
				component: BookList
			},
			//添加商品列表
			{
				path: 'addBookList',
				name: 'AddBookList',
				component: AddBookList
			},
			// 重置密码
			{
				path: 'updataPwd',
				name: 'UpdataPwd',
				component: UpdataPwd
			},
			// 管理员添加
			{
				path: 'admAdd',
				name: 'AdmAdd',
				component: AdmAdd
			},

			// 订单详情
			{
				path: 'orderDetail',
				name: 'OrderDetail',
				component: OrderDetail
			},
		]
	}
]

const router = new VueRouter({
	routes
})

router.afterEach((to) => {
	document.title = to.meta.title;
})

export default router;